package shapes;

import processing.core.PApplet;

public class Sector implements Shape{
	public static final float TWO_PI = PApplet.PI * 2f;
	float startAngle, endAngle, radius, scale;
	int baseRes, res;
	float angleStep;
	
	public Sector(float startAngle, float endAngle, float radius, int res) {
		setStartAngle(startAngle);
		setEndAngle(endAngle);
		this.radius = radius;
		this.baseRes = res;
		scale = 1;
	}

	public void draw(PApplet pa) {
		float angle = startAngle;
		pa.beginShape(PApplet.TRIANGLE_STRIP);
		for(int i = 0; i < res; i++){
			pa.vertex(pa.cos(angle) * radius, pa.sin(angle) * radius, 0);
			angle += angleStep;
		}
		pa.endShape();
	}
	
	public void setStartAngle(float angle){
		startAngle = angle;
		res = Math.round(baseRes * (endAngle - startAngle) / TWO_PI);
		angleStep = (endAngle - startAngle) / (float)res;
	}
	
	public void setEndAngle(float angle){
		endAngle = angle;
		res = Math.round(baseRes * (endAngle - startAngle) / TWO_PI);
		angleStep = (endAngle - startAngle) / (float)res;
	}
	
	public void setRadius(float radius){
		this.radius = radius;
	}
	
	public void scale(float s) {
	}

}
